/**********************************************************

***********************************************************
File Name		     : DBLogger.cs
Project Code		 : 
Author  			 :
Created on	    	 :
***********************************************************
Type		    	 : C# Source file
Purpose			     : This class has static method to log the 
                       Error/Exception to DataBase.
Pre-requisites		 : 
Known Bugs		     : 
Associated File(s)	 :
Table(s)/Procedure(s):
Method(s)    		 : WriteToDB
See Also			 :
***********************************************************
Revision History	 :


***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data.Common;
using System.Web;
using System.Data;
using DBHelper;

namespace ExceptionLogger
{
    class DBLogger
    {
        /// <summary>
        ///  Method to Log the Error/exception to Database
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="ClientID"></param>
        /// <param name="UserName"></param>
        public static void WriteToDB(Exception Exc, string ClientID, string UserName)
        {
            SqlHelper db = new SqlHelper();           
            db.AddParameter ("@vchMessage", Exc.Message, SqlDbType.VarChar);
            db.AddParameter ("@vchStackTrace", Exc.StackTrace, SqlDbType.VarChar);
            db.AddParameter ("@vchExceptionType", Convert.ToString(Exc.GetType ()), SqlDbType.VarChar);
            db.AddParameter ("@vchTargetSite", Convert.ToString(Exc.TargetSite), SqlDbType.VarChar);
            db.AddParameter ("@vchUserName", UserName, SqlDbType.VarChar);
            db.AddParameter ("@vchClientID", ClientID, SqlDbType.VarChar);
            db.ExecuteNonQuery("CMT_ExceptionLog", CommandType.StoredProcedure);

        }
    }
}
